home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / src / private / pdcdebug.c next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  2.0 KB  |  75 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. #include <stdarg.h>
  20. #include <string.h>
  21. #define    CURSES_LIBRARY    1
  22. #include <curses.h>
  23. #undef    PDC_debug
  24.  
  25. #ifdef PDCDEBUG
  26. char *rcsid_PDCdebug  = "$Id$";
  27. #endif
  28.  
  29.     bool trace_on = FALSE;
  30.  
  31. /*man-start*********************************************************************
  32.  
  33.   PDC_debug()    - Write debugging info to log file.
  34.  
  35.   PDCurses Description:
  36.      This is a private PDCurses routine.
  37.  
  38.   PDCurses Return Value:
  39.      No return value.
  40.  
  41.   PDCurses Errors:
  42.      No errors are defined for this function.
  43.  
  44.   Portability:
  45.      PDCurses    void PDC_debug( char *,... );
  46.  
  47. **man-end**********************************************************************/
  48.  
  49. void    PDC_debug( char *fmt, ... )
  50. {
  51.     va_list args;
  52. FILE *dbfp=NULL;
  53. char buffer[256]="";
  54.  
  55. /*
  56.  * open debug log file append
  57. */
  58.     if (!trace_on)
  59.         return; 
  60.     dbfp = fopen("trace","a");
  61.     if (dbfp == NULL)
  62.     {
  63.         fprintf( stderr, "PDC_debug(): Unable to open debug log file\n" );
  64.         exit( 5 );
  65.     }
  66.  
  67.     va_start(args, fmt);
  68.     vsprintf(buffer,fmt,args);
  69.     fputs(buffer,dbfp);
  70.     va_end(args);
  71.     fclose(dbfp);
  72.     return;
  73. }
  74.